package generic;

/**
 * @description: 泛型测试类
 * @author: apple
 * @date:  2021/12/8 2:20 下午
 * @version 1.0
 **/
public class Fruit {

    void hello() {}

    public static void main(String[] args) {
        Fruit f = new Apple();
        Plate<Fruit> plate = new Plate<>(f);
        plate.show();
        // String没有继承Fruit
        //Plate<String> s = new Plate<String>();
    }
}

class Apple extends Fruit {


}

/*边界控制，T是继承字Fruit的，类中T可以访问Fruit的成员和方法，客户端只能是Fruit的子类*/
class Plate<T extends Fruit> {
    private T item;
    public Plate(T t) {
        this.item = t;
    }
    public void show() {
        System.out.println(item);
    }


}
